#include "wifiboy32.h"
#include "LCDWIKI_GUI.h" //Core graphics library
#include "LCDWIKI_SPI.h" //Hardware-specific library

//paramters define
#define MODEL ILI9341
#define CS    A5
#define RST   A4    
#define CD    A3
#define MOSI  A2
#define MISO  13
#define SCK   A1
#define LED   A0   //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3V

//the definiens of software spi mode as follow:
//if the IC model is known or the modules is unreadable,you can use this constructed function

//software spi
LCDWIKI_SPI tft(MODEL,CS,CD,MISO,MOSI,RST,SCK,LED); //model,cs,dc,miso,mosi,reset,sck,led

//define some colour values
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

void wb32_init()
{
  tft.Init_LCD();
  tft.Fill_Screen(BLACK);
}

void wb32_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
{
	tft.Set_Draw_color(color);
	tft.Fill_Rectangle(x, y, x+w-1, y+h-1);
}

void wb32_setTextColor(uint16_t c1, uint16_t c2)
{
	tft.Set_Text_colour(c1);
	tft.Set_Text_Back_colour(BLACK);
}

int wb32_drawString(const char *string, uint16_t poX, uint16_t poY, uint8_t size, uint8_t mag)
{
	tft.Set_Text_Size(size);
	tft.Print_String(string, poX, poY);
	return 0;
}

void wb32_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
{
	tft.Set_Draw_color(color);
	tft.Draw_Line(x, y, x, y+h);
}

void wb32_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
{
	tft.Set_Draw_color(color);
	tft.Draw_Line(x, y, x+w, y);
}

